<template>
	<view class="" style="position: relative;background: #F0F1F6;">
		<!-- 背景 -->
		<view class="bg1">
			<image :src="imgHead+'card/photo/20250523/1747968347746.png'" mode=""></image>
		</view>
		<view class="bg2" :style="'background: url('+imgHead+'card/photo/20250523/1747968648634.png) center top/100% 604rpx no-repeat;top:400rpx'">
		</view>
		<!-- 内容 -->
		<view class="containers" :style="'padding-top:200rpx;'" v-if="userInfo&&userInfo.id">
			<!-- 用户信息 -->
			<view class="user-info" @click="toPathFn('/pages/my/updateUser')">
				<view class="avatar">
					<image :src="(userInfo.avatar&&userInfo.avatar!='null')?userInfo.avatar:require('@/static/logo.png')" mode=""></image>
				</view>
				<view class="info">
					<view class="name">{{ userInfo.nickName }}</view>
					<view class="phone" v-if="userInfo.phone">{{ userInfo.phone }}</view> 
				</view>
			</view>
			<view class="commission-box flex-wrp flex-jun" @click="myPriceFn">
				<view class="my-commission flex-jun flex-column">
					<view class="text">我的余额</view>
					<view class="money">{{ userInfo.commissionAmount?userInfo.commissionAmount:0 }}</view>
				</view>
				<view class="details-box flex-wrp">
					<view class="">提现</view>
					<image :src="imgHead+'card/photo/20250523/1747965639982.png'" mode=""></image>
				</view>
			</view>
			<view class="activity-orders-box flex-wrp">
				<view class="flex-wrp flex-jun" @click="toMyspaceFn">
					<text class="">我的报告</text>
					<image :src="imgHead+'card/photo/20250523/1747967061718.png'" mode=""></image>
				</view>
				<view class="flex-wrp flex-jun" style="margin-left: 22rpx;" @click="toAddFn">
					<text class="">发布报告</text>
					<image :src="imgHead+'card/photo/20250523/1747967039179.png'" mode=""></image>
				</view>
			</view>
			<!--  -->
			<view class="list-wrap">
				<view class="item flex-wrp flex-jun" v-for="(item, index) in filteredMenuList" :key="item.id" @click="toTab(item)">
					<view class="item-left flex-wrp">
						<image v-if="item.type==1" :src="item.icon" mode=""></image>
						<image v-else :src="imgHead+item.icon" mode=""></image>
						<view class="">{{item.name}}</view>
					</view>
					<view class="item-right flex-wrp">
						<image :src="imgHead+'card/photo/20250523/1747968012359.png'" mode=""></image>
					</view>
				</view>
			</view>
		</view><image src="@/static/yj.png" mode=""></image>
	</view>
</template>

<script>
	export default {
		data (){
			return {
				imgHead: 'https://qr-card.oss-accelerate.aliyuncs.com/',
				userInfo:{},
				list:[
					{ id: 2, name: '修改密码', icon: 'card/photo/20250523/1747967942730.png' },
					{ id: 5, name: '订购清单', icon: 'card/photo/20250523/1747967914992.png' ,identity:1},
					{ id: 7, name: '我的发票', icon: 'https://xcx.daishulincun.cn/api/upload/20250909/9d48e44b-8220-4b42-8685-0769a82005b7.png',type:1 },
					// { id: 3, name: '清除缓存', icon: 'card/photo/20250523/1747967928848.png' },
					{ id: 8, name: '佣金列表', icon:require('@/static/yj.png'),type:1 },
					{ id: 4, name: '设置', icon: 'card/photo/20250523/1747967957299.png' },
					{ id: 6, name: '联系客服', icon: 'card/photo/20250512/1747047916622.png' },
				],
				kefu:'',
			}
		},
		computed: {
		    filteredMenuList() {
		      return this.list.filter(item => {
		        // 如果没有identity限制，或者有identity限制且匹配当前用户身份，则显示
		        return !item.identity || item.identity === this.userInfo.identity;
		      });
		    }
		  },
		onLoad() {
			
		},
		onShow() {
			if(this.$isLogin())return
			console.log('来咯来咯')
			this.getUserInfoFn()
		},
		methods: {
			getUserInfoFn(){
				this.$http('/api/user/getUserInfo').then(res=>{
					this.userInfo = res.result
					uni.setStorageSync('userInfo',res.result)
				})
				this.$http('/config/getConfigByKey',{configKey:'contactPhone'}).then(res=>{
					if(res.result&&res.result&&res.result.configValue){
						this.kefu = res.result.configValue
					}
				})
			},
			toTab(item) {
				if(item.id == 3) {
					uni.showLoading({mask:true})
						uni.clearStorageSync()
					setTimeout(()=>{
						uni.hideLoading()
						uni.showToast({
							title:'清除缓存成功',
							icon:'none'
						})
						uni.reLaunch({
							url:'/pages/my/login'
						})
					},2000)
				}
				if(item.id == 2) {
					this.toPathFn('/pages/my/password')
				}
				if(item.id == 4) {
					this.toPathFn('/pages/my/updateUser')
				}
				if(item.id == 5) {
					this.toPathFn('/pages/order/order')
				}
				if(item.id == 6) {
					uni.makePhoneCall({
						phoneNumber: this.kefu
					});
				}
				if(item.id == 7) {
					this.toPathFn('/pages/my/fpList')
				}
				if(item.id == 8) {
					this.toPathFn('/pages/my/commissionList')
				}
				
			},
			toAddFn(){
				this.toPathFn('/pages/space/add')
			},
			toMyspaceFn(){
				this.toPathFn('/pages/space/list')
			},
			myPriceFn(){
				this.toPathFn('/pages/my/money')
			},
			toPathFn(url){
				uni.navigateTo({
					url:url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.bg1{
		width: 100%;
		height: 604rpx;
		position: absolute;
		top: 0;
		z-index: 1;
	}
	.bg2{
		width: 100%;
		height: 530rpx;
		position: absolute;
		top: 410rpx;
		z-index: 2;
	}
	.containers{
		width: 100%;
		padding: 0 26rpx;
		box-sizing: border-box;
		position: relative;
		z-index: 3;
	}
	
	image{
		width: 100%;
		height: 100%;
	}
	view{
		box-sizing: border-box;
	}
	.flex-column{
		flex-direction: column;
	}
	.user-info{
		height: 132rpx;
		margin: 22rpx 0 44rpx;
		display: flex;
		align-items: center;
		.avatar{
			width: 132rpx;
			height: 132rpx;
			overflow: hidden;
			border-radius: 50%;
		}
		.info{
			display: flex;
			flex-direction: column;
			margin-left: 34rpx;
			.name{
				font-weight: 500;
				font-size: 40rpx;
				color: #333333;
				line-height: 40rpx;
				font-weight: bold;
			}
			.phone{
				font-weight: 400;
				font-size: 32rpx;
				color: rgba(0,0,0,0.6);
				line-height: 32rpx;
				margin-top: 20rpx;
			}
		}
	}
	.commission-box{
		height: 180rpx;
		background: linear-gradient( 90deg, #4D9DFE 0%, #8FD0FE 100%);
		box-shadow: 0rpx 0rpx 44rpx 0rpx rgba(78,158,254,0.5);
		border-radius: 22rpx 22rpx 22rpx 22rpx;
		padding: 34rpx 34rpx 34rpx 56rpx;
		margin-bottom: 22rpx;
		box-sizing: border-box;
		.my-commission{
			height: 100%;
			display: flex;
			.text{
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 400;
				font-size: 26rpx;
				color: #FFFFFF;
				line-height: 26rpx;
			}
			.money{
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 500;
				font-size: 54rpx;
				color: #FFFFFF;
				line-height: 54rpx;
			}
		}
		.details-box{
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: 400;
			font-size: 26rpx;
			color: #FFFFFF;
			line-height: 26rpx;
			image{
				width: 32rpx;
				height: 32rpx;
				margin-left: 12rpx;
			}
		}
	}
	.activity-orders-box{
		height: 164rpx;
		margin-bottom: 22rpx;
		view{
			flex: 1;
			padding: 34rpx;
			height: 164rpx;
			background: #FFFFFF;
			border-radius: 22rpx 22rpx 22rpx 22rpx;
			text{
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 400;
				font-size: 36rpx;
				color: #333333;
				line-height: 36rpx;
			}
			image{
				width: 98rpx;
				height: 98rpx;
			}
		}
	}
	.list-wrap{
		background: #FFFFFF;
		border-radius: 18rpx 18rpx 18rpx 18rpx;
		padding: 0 34rpx;
		margin-bottom: 22rpx;
		.item{
			height: 132rpx;
			background-color: transparent;
			margin: 0;
			padding: 0;
			&::after {
				border: none;
			}
			.item-left{
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 400;
				font-size: 32rpx;
				color: #333333;
				line-height: 32rpx;
				image{
					width: 36rpx;
					height: 36rpx;
					margin-right: 22rpx;
				}
			}
			.item-right{
				width: 10rpx;
				height: 18rpx;
			}
		}
	}
</style>